Skip to content

Conversation

@TimWolla
Copy link
Member

Thinking about #20208 (comment) this change seems to be most in line with the current semantics of distinguishing between null and "" for WHATWG. If we decide that null doesn't make sense for WHATWG, we can still change this, but for now this seems to be an actual bug fix.


The URL serializing algorithm from the WHATWG URL Standard uses an “includes credentials” rule to decide whether or not to include the @ in the output, indicating the presence of a userinfo component in RFC 3986 terminology. Use this rule to determine whether or not an empty username or password should be returned as the empty string (present but empty) or NULL (not present).

…ters

The URL serializing algorithm from the WHATWG URL Standard uses an “includes
credentials” rule to decide whether or not to include the `@` in the output,
indicating the presence of a userinfo component in RFC 3986 terminology. Use
this rule to determine whether or not an empty username or password should be
returned as the empty string (present but empty) or NULL (not present).
Copy link
Member

@kocsismate kocsismate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pretty much makes sense to me :)

@kocsismate
Copy link
Member

P.S.: Now that I'm working on adding more tests, I realized that the RFC3986 implementation may also benefit from the same return value consolidation:

@kocsismate
Copy link
Member

Oops, a few tests fail

@TimWolla
Copy link
Member Author

Oops, a few tests fail

For this one I wanted to wait a bit whether or not the upstream lexbor issue is acknowledged before working around it.

This nicely sidesteps the undefined behavior with passing a `(NULL, 0)` pair
without needing manual logic.
@TimWolla
Copy link
Member Author

TimWolla commented Nov 1, 2025

While upstream seems to have acknowledged the issue, a fix is not yet available. I've therefore worked around the (NULL, 0) case in php-src.

@TimWolla
Copy link
Member Author

TimWolla commented Nov 1, 2025

I've therefore worked around the (NULL, 0) case in php-src.

I can't wait for https://developers.redhat.com/articles/2024/12/11/making-memcpynull-null-0-well-defined to happen.

@TimWolla TimWolla merged commit 81f6ba5 into php:PHP-8.5 Nov 1, 2025
10 checks passed
TimWolla added a commit that referenced this pull request Nov 1, 2025
* PHP-8.5:
  uri: Use the “includes credentials” rule for WhatWg user/password getters (#20303)
@TimWolla TimWolla deleted the uri-whatwg-userinfo branch November 1, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants